﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SpriteGame.Rendering;

namespace SpriteGame.Effects.Blood
{
    public class BloodParticle
    {
        const float gravityY = -(1f / 60f) * 50;
        Texture2D texture;
        Vector2 position;
        Vector2 velocity;
        Single scale;
        Boolean alive;

        public Boolean Alive
        {
            get { return alive; }
            set { alive = value; }
        }

        public BloodParticle(Texture2D _texture)
        {
            alive = false;
            texture = _texture;
            scale = 1;
        }

        public void InitParticle(Vector2 _position, Vector2 _velocity, Single _scale)
        {
            alive = true;
            position = _position;
            velocity = _velocity;
            scale = _scale;
        }

        public void Update(Int64 elapsedMs)
        {
            velocity.Y += gravityY * ((float)elapsedMs / 1000f);
            position += velocity;

         //   if (!_vpRect.Contains((int)position.X, (int)position.Y))
         //       alive = false;
        }

        public void Draw(ShapeRenderer _spriteBatch)
        {
            if (alive)
            {
                _spriteBatch.DrawQuad(position, 0.0f, texture.Width * scale, texture.Height * scale, texture);
            }
                //_spriteBatch.Draw(texture, position, null, Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 1);
        }

    }
}
